home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / closer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  898 b   |  53 lines

  1. # include    <ingres.h>
  2. # include    <access.h>
  3. # include    <catalog.h>
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)closer.c    8.1    12/31/84)
  7.  
  8. /*
  9. **    closer - close a relation
  10. **
  11. **    CLOSER is used to close a relation which was opened by OPENR.
  12. **    CLOSER should always be called once for each OPENR.
  13. **
  14. **    function values:
  15. **
  16. **        <0  fatal error
  17. **         0  success
  18. **         1  relation was not open
  19. */
  20.  
  21. closer(d)
  22. DESC    *d;
  23. {
  24.     register DESC    *dx;
  25.     register int    i;
  26.  
  27.     dx = d;
  28. #    ifdef xATR1
  29.     if (tTf(21, 8))
  30.         printf("closer: %.14s,%ld\n", dx->reldum.relid, dx->reladds);
  31. #    endif
  32.  
  33.     if (i = noclose(dx))
  34.         return (i);
  35.  
  36.     flush_rel(dx, TRUE);    /* No error is possible since noclose()
  37.                 ** has already flushed any pages
  38.                 */
  39.  
  40.     if (close(dx->relfp))    /*close the relation*/
  41.         i = acc_err(AMCLOSE_ERR);
  42.  
  43.     dx->relopn = 0;
  44.  
  45.     if (dx->reldum.reldim > 0)
  46.     {
  47.         /* close btreesec */
  48.         closer(dx->relbtree);
  49.         close(dx->btree_fd);
  50.     }
  51.     return (i);
  52. }
  53.